package lxt.action;

import java.util.List;

import lxt.action.core.ActionSupport;
import lxt.entity.BorrowTruckInfo;
import lxt.service.BorrowTruckService;

public class BorrowTruckAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	/**
	 * 定义成员变量
	 */
	private String id;
    private String truckId;
    private String ownerName;
    private String isPayed;
    private String flag;
    /**
	 * 返回结果集
	 */
    private List<BorrowTruckInfo> BorrowTrucks;
    /**
     * 定义接口
     */
    private BorrowTruckService borrowTruckService;
    /**
	 * 定义分页成员变量
	 */
	private Integer pageSize = 10;
	private String currPage = "1";
	private Integer total;
    /**
	 * 分页查询
	 * @return
	 */
	
	@SuppressWarnings("finally")
	public String loadAll(){
		try{
			//定义从第几条显示
			int offset = (Integer.parseInt(currPage) - 1) * pageSize;
			BorrowTrucks = this.borrowTruckService.loadBorrowTruck(truckId, ownerName,isPayed, offset, pageSize);
			total = this.borrowTruckService.loadAllBorrowTruckCount(truckId, ownerName,isPayed);
		}catch(Exception ex){
			ex.printStackTrace();
			this.addActionMessage("操作失败，请检查重新操作.");
		}
		finally{
			return SUCCESS;
		}
	}
	/**
	 * 修改结清状态
	 * @return
	 */
	public String update(){
		try{
			System.out.println(this.id);
			System.out.println(flag);
			BorrowTruckInfo bo = this.borrowTruckService.loadBorrowTruckById(this.id);
			bo.setIsPayed(Integer.parseInt(this.flag));
			this.borrowTruckService.updateBorrowTruck(bo);
		}catch(Exception ex){
			ex.printStackTrace();
			this.addActionMessage("操作失败，请检查重新操作.");
		}
		
		return SUCCESS;
	}
	/**
	 * get set
	 */
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getTruckId() {
		return truckId;
	}
	public void setTruckId(String truckId) {
		this.truckId = truckId;
	}
	public String getOwnerName() {
		return ownerName;
	}
	public void setOwnerName(String ownerName) {
		this.ownerName = ownerName;
	}
	public String getIsPayed() {
		return isPayed;
	}
	public void setIsPayed(String isPayed) {
		this.isPayed = isPayed;
	}
	public List<BorrowTruckInfo> getBorrowTrucks() {
		return BorrowTrucks;
	}
	public void setBorrowTrucks(List<BorrowTruckInfo> borrowTrucks) {
		BorrowTrucks = borrowTrucks;
	}
	public BorrowTruckService getBorrowTruckService() {
		return borrowTruckService;
	}
	public void setBorrowTruckService(BorrowTruckService borrowTruckService) {
		this.borrowTruckService = borrowTruckService;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public String getCurrPage() {
		return currPage;
	}
	public void setCurrPage(String currPage) {
		this.currPage = currPage;
	}
	public Integer getTotal() {
		return total;
	}
	public void setTotal(Integer total) {
		this.total = total;
	}
	public String getFlag() {
		return flag;
	}
	public void setFlag(String flag) {
		this.flag = flag;
	}
	
}
